home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kspell2 / broker.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.3 KB  |  137 lines

  1. // -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*-
  2. /**
  3.  * broker.h
  4.  *
  5.  * Copyright (C)  2003  Zack Rusin <zack@kde.org>
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  20.  * 02110-1301  USA
  21.  */
  22. #ifndef KSPELL_BROKER_H
  23. #define KSPELL_BROKER_H
  24.  
  25. #include <ksharedptr.h>
  26.  
  27. #include <qobject.h>
  28. #include <qstringlist.h>
  29. #include <qstring.h>
  30.  
  31. class KSharedConfig;
  32. template <typename T>
  33. class QPtrDict;
  34.  
  35. namespace KSpell2
  36. {
  37.     class Settings;
  38.     class Dictionary;
  39.     class DefaultDictionary;
  40.  
  41.     /**
  42.      * @short Class used to deal with dictionaries
  43.      *
  44.      * This class manages all dictionaries. It's the top level
  45.      * KSpell2 class, you can think of it as the kernel or manager
  46.      * of the KSpell2 architecture.
  47.      */
  48.     class KDE_EXPORT Broker : public QObject,
  49.                    public KShared
  50.     {
  51.         Q_OBJECT
  52.     public:
  53.         typedef KSharedPtr<Broker> Ptr;
  54.         /**
  55.          * Constructs the broker.
  56.          *
  57.          * It's very important that you assign it to Broker::Ptr
  58.          * as soon as possible. Broker is reference counted so
  59.          * if you don't want to have it deleted under you simply
  60.          * have to hold it in a Broker::Ptr for as long as you're
  61.          * using it.
  62.          *
  63.          * @param config is the name of config file which
  64.          *        broker should use to read default language
  65.          *        and default client values. If no value will
  66.          *        be passed Broker will use global kspellrc file.
  67.          */
  68.         static Broker *openBroker( KSharedConfig *config = 0 );
  69.  
  70.     public:
  71.         ~Broker();
  72.  
  73.         /**
  74.          * Function returns the so-called DefaultDictionary. It's a
  75.          * special form a dictionary which automatically mutates
  76.          * according to changes tot the KSpell2::Settings object.
  77.          * You also can't delete it like other dictionaries since
  78.          * it's owned by the Broker and it will take care of it.
  79.          */
  80.         DefaultDictionary *defaultDictionary() const;
  81.  
  82.         /**
  83.          * Returns dictionary for the given language and preferred client.
  84.          *
  85.          * @param language specifies the language of the dictionary. If an
  86.          *        empty string will be passed the default language will
  87.          *        be used. Has to be one of the values returned by
  88.          *        \ref languages()
  89.          * @param client specifies the preferred client. If no client is
  90.          *               specified a client which supports the given
  91.          *               language is picked. If a few clients supports
  92.          *               the same language the one with the biggest
  93.          *               reliability value is returned.
  94.          *
  95.          */
  96.         Dictionary *dictionary(
  97.             const QString& language = QString::null,
  98.             const QString& client = QString::null ) const;
  99.  
  100.         /**
  101.          * Returns names of all supported clients (e.g. ISpell, ASpell)
  102.          */
  103.         QStringList clients() const;
  104.  
  105.         /**
  106.          * Returns a list of supported languages.
  107.          */
  108.         QStringList languages() const;
  109.  
  110.         /**
  111.          * Returns the Settings object used by the broker.
  112.          */
  113.         Settings *settings() const;
  114.     signals:
  115.         /**
  116.          * Signal is emitted whenever the Settings object
  117.          * associated with this Broker changes.
  118.          */
  119.         void configurationChanged();
  120.  
  121.     protected:
  122.         friend class Settings;
  123.         void changed();
  124.     private:
  125.         Broker( KSharedConfig *config );
  126.         void loadPlugins();
  127.         void loadPlugin( const QString& );
  128.     private:
  129.         class Private;
  130.         Private *d;
  131.     private:
  132.         static QPtrDict<Broker> *s_brokers;
  133.     };
  134. }
  135.  
  136. #endif
  137.